package org.example.afiona.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.example.afiona.common.VO.ResultVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

/**
 * @Author: leo
 * @date: 2021/6/9
 */
@RestController
@Api(tags = "用户")
public class UserController {

    @Autowired
    private RestTemplate restTemplate;

        private static final String ORIGINAL_INVOKE_URL = "http://localhost:8101";
    private static final String RIBBON_INVOKE_URL = "http://PROVIDER-ORDER-RIBBON";

    @GetMapping("/user/original/order/status")
    @ApiOperation("获取用户订单状态,原生调用")
    public ResultVO<Integer> getUserOrderStatus() {
        ResultVO<Integer> resultVO = restTemplate.getForObject(ORIGINAL_INVOKE_URL + "/order/status", ResultVO.class);
        return resultVO;
    }

    @GetMapping("/user/ribbon/order/status")
    @ApiOperation("获取用户订单状态,通过ribbon获取")
    public ResultVO<Integer> getUserOrderStatusByRibbon() {
        ResultVO<Integer> resultVO = restTemplate.getForObject(RIBBON_INVOKE_URL + "/order/status", ResultVO.class);
        return resultVO;
    }
}
